<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->

<link href="<%=basePath %>resources/css/bootstrap.min.css" rel="stylesheet" media="screen">
<script src="<%=basePath %>resources/jslib/jquery.js"></script>
<script src="<%=basePath %>resources/jslib/bootstrap.min.js"></script>
<script  type="text/javascript">

//登录
	function saveDeviceInfo() {
		$("#mes").show();
		$("#mes").html("&nbsp;&nbsp;正在通讯中...");
		
		var mingCheng=$("#mingCheng").val();
		if(mingCheng.length<0){
			$("#mes").html("&nbsp;&nbsp;材料名称不能为空");
			return ;
		}
		
		var xingHao=$("#xingHao").val();
		if(xingHao.length<0){
			$("#mes").html("&nbsp;&nbsp;材料型号不能为空");
			return ;
		}
		
		
		var caigouInfo=$("#caigouInfo").val();
		if(caigouInfo.length<0){
			$("#mes").html("&nbsp;&nbsp;采购员信息不能为空");
			return ;
		}
		
		//登录处理
		var param={"linJianId":$("#lingJianId").val(),
				"name":$("#mingCheng").val(),
				"xinghao":$("#xingHao").val(),
				"factoryId":$("#factoryId").val(),
				  "caigouyuan":$("#caigouInfo").val()
				  };
		$.ajax({
			type: "post",
			contentType: "application/json;charset=utf-8",
			url : "<%=basePath %>lingJian/addCaigouInfo.action",
			data :JSON.stringify(param) ,
			success : function(data){
                       if(data.code=="0000"){
	                          alert("添加成功"); 
	                       }else{
	                          $("#mes").html(data.code+"##"+data.message);
	                        }
                      
             },
			 dataType : "json"
		});
	}
</script>
</head>
<body>
<ol class="breadcrumb">
	<li><a href="#">登陆</a></li>
	<li><a href="#">首页</a></li>
	<li class="active">零件采购信息详情添加</li>
</ol>


<form class="form-horizontal" role="form">
 
 <input class="form-control" id="lingJianId" type="hidden" value="${lingJian.id }" >
  <div class="form-group">
    <label class="col-sm-2 control-label">零件编号：</label>
    <div class="col-sm-10">
      <input class="form-control" readonly="readonly" id="bianHao" type="text"  value="${lingJian.bianHao }" >
    </div>
  </div>
  
  <div class="form-group">
    <label class="col-sm-2 control-label">零件名称：</label>
    <div class="col-sm-10">
      <input class="form-control" id="deviceName" readonly="readonly" type="text" value="${lingJian.name }">
    </div>
  </div>
  
  
   <div class="form-group">
    <label class="col-sm-2 control-label">零件型号：</label>
    <div class="col-sm-10">
      <input class="form-control" id="xingHao"  readonly="readonly" type="text"  value="${lingJian.xingHao }">
    </div>
  </div>
 
 <div class="form-group">
   <label class="col-sm-2 control-label" for="inputSuccess">供应商选择：</label>
    <div class="col-sm-10">
      <select class="form-control"  id="factoryId">
      <c:forEach items="${factory}" var="item"  varStatus="status">
          <option value="${item.id}">${item.name}</option>
        </c:forEach>
       </select>
    </div>
  </div>
 
  <div class="form-group">
     <label class="col-sm-2 control-label">采购员信息：</label>
       <div class="col-sm-10">
    <input class="form-control" id="caigouInfo"   placeholder="请输入操作者信息"></input>
      </div>
  </div>
  
   <div class="form-group">
     <label class="col-sm-2 control-label">采购材料名称：</label>
       <div class="col-sm-10">
     <input class="form-control"  id="mingCheng"   placeholder="请输入采购材料名称"></input>
      </div>
  </div>
  
  <div class="form-group">
     <label class="col-sm-2 control-label">采购材料型号：</label>
       <div class="col-sm-10">
     <input class="form-control" id="xingHao"   placeholder="请输入采购材料型号"></input>
      </div>
  </div>
   <div class="form-group">
       <label class="col-sm-2 control-label" for="inputSuccess"></label>
       <button type="button"  class="btn btn-success"  onclick="saveDeviceInfo()">确认保存</button>
      
    </div>
     <div class="form-group">
       <label class="col-sm-2 control-label" for="inputSuccess"></label>
       <p class="text-success" id="mes"></p>
    </div>
</form>

</body>
</html>